/* 
 * File:   Data.h
 * Author: song
 *
 * Created on 2010年10月28日, 下午1:11
 */

#ifndef _DATA_H
#define	_DATA_H

#include<stdio.h>
#include<iostream>
#include <queue>
#include <vector>
using namespace std;
#include <cv.h>
#include"highgui.h"
#include"cxcore.h"
#include "cvaux.h"

//通过 c++ wrapper 的图像像素的直接访问
template<class T> class Image
{
  private:
  IplImage* imgp;
  public:
  Image(IplImage* img=0) {imgp=img;}
  ~Image(){imgp=0;}
  void operator=(IplImage* img) {imgp=img;}
  inline T* operator[](const int rowIndx) {
    return ((T *)(imgp->imageData + rowIndx*imgp->widthStep));}
};

typedef struct{
  unsigned char b,g,r;
} RgbPixel;

typedef struct{
  float b,g,r;
} RgbPixelFloat;

typedef Image<RgbPixel>       RgbImage;
typedef Image<RgbPixelFloat>  RgbImageFloat;
typedef Image<unsigned char>  BwImage;
typedef Image<float>          BwImageFloat;

typedef struct trackObject
{
    int id, lostfrm;
    bool matched;
    CvPoint pt0, pt1;
    CvRect rect;
    CvConnectedComp comp;
    CvBox2D box;
    IplImage *image, *mask, *hsv, *hue, *backProject;
    //直方图
    CvHistogram *hist;
}
trackObject;

typedef struct Camera
{
    //直方图
    CvHistogram *hist;

    //帧图像 前景和后景 当前帧灰度化图像 以及对应矩阵
    IplImage *pFrame, *pPre, *pFrImg, *pBkImg, *pGray, *tmpBk;
    CvMat* pFrameMat, *pFrMat, *pBkMat, *pGrayMat, *tmpBkMat;

    //从摄像头中读取图像的捕捉器
    CvCapture *capture;
};

#endif	/* _DATA_H */

